/**
 * Coryright 2015-2020 www.eyaomall.cn
 * All rights reserved.
 * @author tumingjun
 * @date 2016年8月10日
 *
 */

package com.eyaomall.wxmanage.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.eyaomall.wxmanage.model.pojo.ResFlag;
import com.eyaomall.wxmanage.model.vo.MerchantsVO;
import com.eyaomall.wxmanage.model.vo.ShopExtVO;
import com.eyaomall.wxmanage.model.vo.ShopVO;
import com.eyaomall.wxmanage.service.MerchantsService;
import com.eyaomall.wxmanage.service.ShopExtService;
import com.eyaomall.wxmanage.service.ShopService;
import com.lycheeframework.core.cmp.api.http.GsnData;
import com.lycheeframework.core.cmp.api.http.GsnResponse;
import com.lycheeframework.core.cmp.kit.PageHTTPObject;

/**
 * @author tumingjun
 *
 */
@Controller
@RequestMapping("merchants")
public class MerchantsController {
	
	@Autowired
	private MerchantsService merchantsService;
	
	@Autowired
	private ShopService shopService;
	
	@Autowired
	private ShopExtService shopExtService;
	
	/**
	 * 获取激活列表
	 * @param merchants
	 * @param httpObject
	 * @return
	 */
	@RequestMapping("/page_active")
	public @ResponseBody GsnData pageActive(MerchantsVO merchantsVO,PageHTTPObject httpObject){
		
		return GsnResponse.toData(merchantsService.pageActive(merchantsVO, httpObject));
	}
	
	/**
	 * 获取激活列表
	 * @param merchants
	 * @param httpObject
	 * @return
	 */
	@RequestMapping("/page_unActive")
	public @ResponseBody GsnData pageUnActive(MerchantsVO merchantsVO,PageHTTPObject httpObject){
		
		return GsnResponse.toData(merchantsService.pageUnActive(merchantsVO, httpObject));
	}
	
	/**
	 * 商家信息
	 * @return
	 */
	@RequestMapping("/to_active")
	public String toPage(){
		
		return "merchants/page_active";
	}
	
	/**
	 * 未激活商家信息
	 * @return
	 */
	@RequestMapping("/to_unactive")
	public String toUnactive(){
		
		return "merchants/page_unactive";
	}
	
	/**
	 * 获取激活列表
	 * @param ShopVO
	 * @return
	 */
	@RequestMapping("/active_m")
	public @ResponseBody GsnData activeM(ShopVO shopVO){
		
		return GsnResponse.toData(shopService.activeMerchants(shopVO));
	}
	
	/**
	 * 获取激活列表
	 * @param ShopVO
	 * @return
	 */
	@RequestMapping("/unActive_m")
	public @ResponseBody GsnData unActiveM(ShopVO shopVO){
		
		return GsnResponse.toData(shopService.unActiveMerchants(shopVO));
	}
	
	/**
	 * 开通代理
	 * @param shopExt
	 * @return
	 */
	@RequestMapping("/open_child")
	public @ResponseBody GsnData openChild(ShopExtVO shopExtVO){
		
		return GsnResponse.toData(new ResFlag(shopExtService.openChild(shopExtVO)));
	}
	
	/**
	 * 增加代理
	 * @param shopExt
	 * @return
	 */
	@RequestMapping("/add_child")
	public @ResponseBody GsnData addChild(ShopExtVO shopExtVO){
		
		return GsnResponse.toData(new ResFlag(shopExtService.addChild(shopExtVO)));
	}

}
